# To compile without assertions run 'make -DNDEBUG'

CC=gcc
CFLAGS=$(.MAKEFLAGS) -g -Os -Wall

all: nrg4iso

# The 'osx' target is only here for convenience when
# building a universal binary on OS X.
osx :
	@echo "****************************************"
	@echo "* Building a Mac OS X universal binary *"
	@echo "****************************************"
	@rm -fv *.o nrg4iso
	@make CFLAGS="$(CFLAGS) -arch ppc"
	@mv nrg4iso nrg4iso_ppc
	@rm -fv *.o nrg4iso
	@make CFLAGS="$(CFLAGS) -arch i386"
	@mv nrg4iso nrg4iso_i386
	@rm -fv *.o nrg4iso
	@lipo -create nrg4iso_ppc nrg4iso_i386 -output nrg4iso
	@rm nrg4iso_ppc nrg4iso_i386
	@echo "****************************************"
	@file nrg4iso


nrg4iso: main.o iso9660.o nrg.o cdtext.o crc.o endian.o
	$(CC) $(CFLAGS) -o $@ $> $^

nrgdump: nrgdump.o nrg.o endian.o
	$(CC) $(CFLAGS) -o $@ $> $^

main.o: main.c iso9660.h nrg.h globals.h

iso9660.o: iso9660.c iso9660.h globals.h

nrg.o: nrg.c nrg.h nrg_chunks.h iso9660.h cdtext.h globals.h

cdtext.o: cdtext.c cdtext.h crc.h

crc.o: crc.c crc.h

endian.o: endian.c endian.h globals.h

clean:
	rm -fv *.o nrg4iso
